//
//  SLEmoticonButton.swift
//  Emotion
//
//  Created by lirenqiang on 16/6/2.
//  Copyright © 2016年 lirenqiang. All rights reserved.
//

import UIKit

class SLEmoticonButton: UIButton {

    var emoticon: SLEmoticon? {
        didSet {
            
            if let path = emoticon?.imagePath {
                setImage(UIImage(named: path), forState: .Normal)
                setTitle(nil, forState: .Normal)
            } else {
                
                if let title = emoticon?.emoji {
                    setTitle(title, forState: .Normal)
                    titleLabel?.font = UIFont.systemFontOfSize(32)
                    setImage(nil, forState: .Normal)
                }
                
            }
            
            if emoticon!.isDelete {
                setImage(UIImage(named: "compose_emotion_delete"), forState: .Normal)
            }
            
            if emoticon!.isEmpty {
                setTitle(nil, forState: .Normal)
                setImage(nil, forState: .Normal)
            }
            
        }
    }

}
